﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using RS.DOM.Common;
using RS.DOM.Construction;

namespace RSTestConsole
{
    public class Program
    {
        static void Main(string[] args)
        {
            System.Console.WriteLine("RS Interpretator by VyMa (c)2010");
            System.Console.WriteLine("'Exit' - to exit");

            while (true)
            {
                System.Console.Write(">>");
                string line = System.Console.ReadLine();
                if (line.ToLower() == "exit")
                    break;

                //program
                Document doc = new Document(line);
                doc.Build();
                doc.Execute();

                Console.WriteLine("============ Log ============");
                foreach (string text in doc.Log)
                    Console.WriteLine(text);

                if (!doc.HasError)
                {
                    Console.WriteLine("============ Output ============");
                    Console.WriteLine(doc.Output);
                }
                else
                {
                    Console.WriteLine("========== Error ============");
                    Console.WriteLine(doc.Error);
                }
            }
        }
    }
}
